--=== Created by Lisa 	===--
--=== 		V 1.3 		===--

local oldfriends , oldmobs


function changeOptionFriendMob(_type,_name,_addremove)

--examples	changeOptionFriendMob("mob", "Wolf", "Add")
--examples	changeOptionFriendMob("friend", "Hokeypokey", "Remove")
--examples	changeOptionFriendMob("friend", "reset") 	-- goes back to profile for friend
--examples	changeOptionFriendMob("mob", "reset")		-- goes back to profile for mob

	if _name == nil or _name == "" then
		printf("Need to specify name.\n")
	end

	if _addremove == nil then _addremove = "add" end
	
	addremove = string.lower(_addremove)
	
	if addremove ~= "add" and addremove ~= "remove" then
		printf("Wrong usage of arg#3, _addremove")
	end

	if( _name ) then name = trim(_name) end;
	if _type == "friend" then 
		if oldfriends == nil then
			oldfriends = settings.profile.friends
		end	
		if _name == "reset" then
			settings.profile.friends = oldfriends
			return
		end
		if addremove == "add" then 
			for k,v in ipairs(settings.profile.friends) do
				if v == name then return end
			end
			table.insert(settings.profile.friends, name);
			for k,v in ipairs(settings.profile.friends) do
				printf(k.." "..v.."\n")
			end
		end

		if addremove == "remove" then 
			for k,v in ipairs(settings.profile.friends) do
				if v == name then
				table.remove(settings.profile.friends,k);
				printf("Removing friend "..v.."\n")
				end
				printf(k.." "..v.."\n")
			end
		end
	end
	if _type == "mob" then 
		if oldmobs == nil then
			oldmobs = settings.profile.mobs
		end
		if _name == "reset" then
			settings.profile.mobs = oldfriends
			return
		end
		if addremove == "add" then 
			for k,v in ipairs(settings.profile.mobs) do
				if v == name then return end
			end
			table.insert(settings.profile.mobs, name);
			for k,v in ipairs(settings.profile.mobs) do
				printf(k.." "..v.."\n")
			end
		end

		if addremove == "remove" then 
			for k,v in ipairs(settings.profile.mobs) do
				if v == name then
					table.remove(settings.profile.mobs,k);
					printf("Removing mob "..v.."\n")
				end
				printf(k.." "..v.."\n")
			end
		end	
	end
end